<?php 
include_once 'inc/config.inc.php';
include_once 'inc/mysql.inc.php';
include_once 'inc/tool.inc.php';
$link=connect();
if(!$member_id=is_login($link)){
	skip('login.php', 'error', '请登录之后再发帖!');
}
if(isset($_POST['submit'])){
    $url = $_SERVER["HTTP_REFERER"];
    if (empty($_POST['title'])) {
        skip($url,"error","帖子标题不能为空");
    }
    if (empty($_POST['content'])) {
        skip('member.php?', "error", "请输入帖子内容");
    }
	$_POST=escape($link,$_POST);
	$query = "UPDATE `sfkbbs`.`sfk_content` SET  `title` = {$_POST['title']}, content = {$_POST['content']}, time = NOW()  WHERE id = {$_GET['id']}";
	execute($link,$query);
	/*if ($link->affected_rows) {
//	    skip();
    }*/

}
$template['title']='修改帖子';
$template['css']=array('style/public.css','style/publish.css');
var_dump($_SERVER);
// 帖子信息
$query = "select * from sfk_content where id = {$_GET['id']} limit 1";
$data = execute($link,$query)->fetch_array();
$data['title'] = htmlspecialchars($data['title']);
$data['content'] =nl2br(htmlspecialchars($data['content']));
?>
<?php include 'inc/header.inc.php'?>
	<div id="position" class="auto">
		 <a href="index.php">首页</a> &gt; 修改帖子
	</div>
	<div id="publish">
		<form method="post">
            <h2>标题：</h2><input name="title" value="<?=$data['title']?>" />
			<textarea name="content" class="content"><?=$data['content']?></textarea>
			<input class="publish" type="submit" name="submit" value="" />
			<div style="clear:both;"></div>
		</form>
	</div>
<?php include 'inc/footer.inc.php'?>